package com.ibeetl.admin.api.service;

import com.ibeetl.admin.api.dao.TravelUserDao;
import com.ibeetl.admin.api.entity.Travel_user;
import com.ibeetl.admin.api.web.query.TravelUserQuery;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import org.beetl.sql.core.page.PageRequest;
import org.beetl.sql.core.page.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class UserService  extends CoreBaseService<Travel_user> {
    @Resource
    TravelUserDao travelUserDao;
    public long queryUserIdByPhone(String phone) {
        Long id =travelUserDao.queryUserIdByPhone(phone);
        if(id == null){
            return 0;
        }
        return id;
    }

    public PageResult<Travel_user> queryByCondition(TravelUserQuery condition) {
        PageRequest pageRequest = condition.getPageRequest();
        Map params = condition.getPageParam();
        PageResult ret = travelUserDao.queryByCondition(pageRequest, params);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelTravelUser(List<Long> ids){
        try {
            travelUserDao.batchDelTravelUserByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除TravelUser失败", e);
        }
    }
}
